import Game from "../Game"
import World from "../world/World"
import Snake from "../snake/Snake"
import PlayerSnake from "../snake/PlayerSnake"

/** 游戏事件 */
export namespace GameEvent {
    /** 游戏事件类型 */
    export enum Type {
        /** 游戏帧更新 */
        GAME_UPDATE,
        /** 世界初始化 */
        WORLD_START,
        /** 排行榜更新 */
        RANK_UPDATE,
        /** 蛇增加 */
        SNAKE_ADD,
        /** 蛇移除 */
        SNAKE_REMOVE,
        /** 蛇生成 */
        SNAKE_SPAWN,
        /** 蛇死亡 */
        SNAKE_DIE,
    }

    /** 游戏事件定义 */
    export type Def = {
        [Type.GAME_UPDATE]: IGame,
        [Type.WORLD_START]: IWorld,
        [Type.RANK_UPDATE]: IRankUpdate,
        [Type.SNAKE_ADD]: ISnake,
        [Type.SNAKE_REMOVE]: ISnake,
        [Type.SNAKE_SPAWN]: ISnake,
        [Type.SNAKE_DIE]: ISnake,

    }

    export interface IGame {
        readonly game: Game
    }

    export interface IWorld {
        readonly world: World
    }

    export interface ISnake {
        readonly snake: Snake
    }

    export interface IRankUpdate {
        readonly rankArr: Snake[]
    }

    /** 玩家事件 */
    export interface IPlayer {
        readonly player: PlayerSnake
    }
}